package com.wll.thread.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;

/**
 * @Description: TODO
 * @Author: Wanglulu
 * @Date: 2021/4/29 13:39
 * @Version 0.0.1
 */
public class SquareCalculator {

//    private ExecutorService executor = Executors.newSingleThreadExecutor();
//    ExecutorService executor = Executors.newFixedThreadPool(3);
    ExecutorService executor = ThreadPool.createThead(3);

    public Future<Object> calculate(Integer input) {
        return executor.submit(() -> {
            Thread.sleep(1000);
            System.out.println("input : "+ input);
            return "hello " + input;
        });
    }

    public void shutdown() {
        executor.shutdown();
    }
}
